/*
 *  CS202 - Spring 2009">
 *  Professor: Dr. Michael Peterson">
 *  Student: Deylo Woo (dwoo711@gmail.com) ">
 */
package project_3_v_2;

import javax.swing.*;
import java.awt.*;

/**
 * Base class for all moving objects
 * @author deylo
 */
public class MovingObject {

    protected int _xCoord;
    protected int _yCoord;
    protected int _height;
    protected int _width;
    protected int _rise;
    protected int _run;
    protected int Value;
    protected Color _color;

    /**
     * Constructor method, not really used cuz it creates randomly
     */
    public MovingObject() {
        _xCoord = (int) (Math.random() * 50);
        _yCoord = (int) (Math.random() * 50);
        _height = _width = (int) ((Math.random() * 20) + 10); //range from 10-20
        // _width = (int) ((Math.random() * 20) + 10); //range from 10-20
        _rise = (int) (Math.random() * 10);
        _run = (int) (Math.random() * 10);
        _color = Color.BLUE;
    }

    /**
     * Constructor that pass paramters
     * @param xCoord: x coordinate on screen
     * @param yCoord: y coordinate on screen
     * @param height: height of object
     * @param width: width of object
     * @param rise: vertical velocity
     * @param run: horizontal velocity
     * @param color: color of object
     */
    public MovingObject(int xCoord, int yCoord, int height, int width, int rise, int run, Color color) {
        _xCoord = xCoord;
        _yCoord = yCoord;
        _height = height;
        _width = width;
        _rise = rise;
        _run = run;
        _color = color;
    }

    /**
     * Paint object on screen
     * @param g: graphics to be painted
     */
    public void paint(Graphics g) {
        g.setColor(_color);
        g.fillRect(_xCoord, _yCoord, _width, _height);
    }

    /**
     * Move the missile on screen
     * @param pPanelHeight: pass the panel height for dynamic resize of panel
     * @param pPanelWidth: pass the panel width for dynamic resize of panel
     */
    public void Move(int pPanelHeight, int pPanelWidth) {

        if (_xCoord < (0 - _run) || _xCoord > (pPanelWidth - _width)) {
            _run = -_run;
        }

        if (_yCoord < (0 - _rise) || _yCoord > (pPanelHeight - _height)) {
            _rise = -_rise;
        }

        _xCoord += _run;
        _yCoord += _rise;
    }

    /**
     * @return the _xCoord
     */
    public int getXCoord() {
        return _xCoord;
    }

    /**
     * @param xCoord the _xCoord to set
     */
    public void setXCoord(int xCoord) {
        this._xCoord = xCoord;
    }

    /**
     * @return the _yCoord
     */
    public int getYCoord() {
        return _yCoord;
    }

    /**
     * @param yCoord the _yCoord to set
     */
    public void setYCoord(int yCoord) {
        this._yCoord = yCoord;
    }

    /**
     * @return the _height
     */
    public int getHeight() {
        return _height;
    }

    /**
     * @param height the _height to set
     */
    public void setHeight(int height) {
        this._height = height;
    }

    /**
     * @return the _width
     */
    public int getWidth() {
        return _width;
    }

    /**
     * @param width the _width to set
     */
    public void setWidth(int width) {
        this._width = width;
    }

    /**
     * @return the _rise
     */
    public int getRise() {
        return _rise;
    }

    /**
     * @param rise the _rise to set
     */
    public void setRise(int rise) {
        this._rise = rise;
    }

    /**
     * @return the _run
     */
    public int getRun() {
        return _run;
    }

    /**
     * @param run the _run to set
     */
    public void setRun(int run) {
        this._run = run;
    }

    /**
     * @return the _color
     */
    public Color getColor() {
        return _color;
    }

    /**
     * @param color the _color to set
     */
    public void setColor(Color color) {
        this._color = color;
    }

    /**
     * @return the Value
     */
    public int getValue() {
        return Value;
    }

    /**
     * @param Value the Value to set
     */
    public void setValue(int Value) {
        this.Value = Value;
    }
}
